
#include <stdio.h>
#include <string.h>
#include <stdlib.h>



enum setting{
	OPMODE,
	IP_ADDR,
	PORT,
	TC_BUFSIZE,
	MAX_NUM_CONN,
	FORMAT,
	TAGFUNC,
	TIMEOUT_TYPE,
	TIMEOUT,
	CHANNEL,
	READRANGE,
	DATASPEED,
	DPLR,
	DPLR_SENS,
	DPLR_OUTPUT,
	I1FUNC,
	I2FUNC,
	ACTS_LOOP,
	UD_SEND,
	INCLUDE_DB_SIZE,
	MARK_DIG,
	SC_LEN,
	SC,
	UD_FMT,
	UNLOCK_KEY,
	TC_MODE
};

int main()
{
   //FILE * pFile;
   //setting_struct* settings = (setting_struct*)malloc(sizeof(setting_struct));
   char* set[26];
   char buffer [100];
   char* tok;
   int index;
   FILE * actsflexcof = fopen ("actsflex.conf" , "r");
   if (actsflexcof == NULL) perror ("Error opening file");
   else
   {
     while ( ! feof (actsflexcof) )
     {
       if ( fgets (buffer , 100 , actsflexcof) == NULL ) break;
       if(buffer[0]== '#' || buffer[0] == '\n' || buffer[0] == '\r') continue;

       //  ||buffer[0] == '\f' ||buffer[0] == '\0' || buffer[0] == '\t' ) continue;

       tok = strtok(buffer, "=\r\n");
       index = atoi(tok);
       tok = strtok(NULL, "=\n");
       set[index] = (char*)malloc(sizeof(tok));
       strcpy(set[index], tok);
       /*
       if(!strcmp(tok,"OPMODE"))
       {
    	   tok = strtok(NULL, "=\n");
    	   settings->OPMODE = (char*)malloc(sizeof(tok));
    	   strcpy(settings->OPMODE, tok);
    	   printf("OPMODE FOUND value = %s", settings->OPMODE);
       }
		*/
       printf("Value for the setting %i is %s \n", index, set[index]);
       //printf("%i\n", OPMODE);
     }
     fclose (actsflexcof);
   }
   return 0;
}
